import React, { Component } from "react";
import "./index.less"
import * as echarts from '../ec-canvas/echarts'

 class Echarts extends Component{
    constructor(props) {
          
        super(props);
        this.state = {
            ec: {
                onInit: this.initChart.bind(this)
            }
        }
   }
   
initChart(canvas, width, height, dpr) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height,
    devicePixelRatio: dpr // new
  });
  canvas.setChart(chart);
console.log(this.props);
  this.props.setChartOptions(chart)

  return chart;
}
   render() {
      
        return(
            
             <view className='container'>
                 <ec-canvas id="mychart-dom-pie" canvas-id="mychart-pie" ec={this.state.ec} />
            </view>
            
        )
    }
}

export default Echarts;
